class Solution {
    public int missingNumber(int[] nums) {
        int left = 0; //设置左边界
        int right = nums.length - 1; //设置右边界

        while (left <= right) {
            int mid = (left + right) / 2;
            if (nums[mid] == mid) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return left;
    }
}